<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="common/header.jsp"%>
<div class="clearfix"></div>
<div class="row">
  <div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
      <div class="x_title">
        <h2>修改APP基础信息 <i class="fa fa-user"></i><small>${du.devname}</small></h2>
             <div class="clearfix"></div>
      </div>
      <div class="x_content">
        <form class="form-horizontal form-label-left" action="${pageContext.request.contextPath}/updateAppInfo" method="post" enctype="multipart/form-data">
          <input type="hidden" name="id" id="id" value="${oneAppInfo.id}">
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">软件名称 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="softwareName" class="form-control col-md-7 col-xs-12" 
               data-validate-length-range="20" data-validate-words="1" 
               name="softwareName" value="${oneAppInfo.softwareName}" required="required"
               placeholder="请输入软件名称" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">APK名称 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="APKName" type="text" class="form-control col-md-7 col-xs-12" 
              name="APKName" value="${oneAppInfo.APKName}" readonly="readonly">
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">支持ROM <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="supportROM" class="form-control col-md-7 col-xs-12" 
              	name="supportROM" value="${oneAppInfo.supportROM}" required="required"
              	data-validate-length-range="20" data-validate-words="1" 
              	placeholder="请输入支持的ROM" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">界面语言 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input id="interfaceLanguage" class="form-control col-md-7 col-xs-12" 
              data-validate-length-range="20" data-validate-words="1"  required="required"
              name="interfaceLanguage" value="${oneAppInfo.interfaceLanguage}"
              placeholder="请输入软件支持的界面语言" type="text">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="number">软件大小 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="number" id="softwareSize" name="softwareSize" value="${oneAppInfo.softwareSize}" required="required"
              data-validate-minmax="10,500"  placeholder="请输入软件大小，单位为Mb" class="form-control col-md-7 col-xs-12">
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="number">下载次数 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="number" id="downloads" name="downloads" value="${oneAppInfo.downloads}" required="required"
              data-validate-minmax="10,500"  placeholder="请输入下载次数" class="form-control col-md-7 col-xs-12">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12"  for="select">所属平台 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="hidden" value="${oneAppInfo.flatformId}" id="fid" />
              <select name="flatformId" id="queryFlatformId" class="form-control" required="required">
                <option>--请选择--</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="select">一级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="hidden" value="${oneAppInfo.categoryLevel1}" id="cl1" />
              <select name="categoryLevel1" id="queryCategoryLevel1" class="form-control"  required="required">
                <option>--请选择--</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12"  for="select">二级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
            	<input type="hidden" value="${oneAppInfo.categoryLevel2}" id="cl2" />
              <select name="categoryLevel2" id="queryCategoryLevel2" class="form-control"  required="required">
                <option>--请选择--</option>
              </select>
            </div>
          </div>
          
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="select">三级分类 <span class="required">*</span></label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="hidden" value="${oneAppInfo.categoryLevel3}" id="cl3" />
              <select name="categoryLevel3" id="queryCategoryLevel3" class="form-control"  required="required">
                <option>--请选择--</option>
              </select>
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">APP状态 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
            	<input id="statusName" type="text" class="form-control col-md-7 col-xs-12" 
              	name="statusName" value="${oneAppInfo.statusName}" readonly="readonly">
            </div>
          </div>
          <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="textarea">应用简介 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <textarea id="appInfo" name="appInfo"
              placeholder="请输入本软件的相关信息，本信息作为软件的详细信息进行软件的介绍。" class="form-control col-md-7 col-xs-12">${oneAppInfo.appInfo}</textarea>
            </div>
          </div>
           <div class="item form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">LOGO图片 <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
				<input type="hidden" id="logoPicPath" name="logoPicPath" value="${oneAppInfo.logoPicPath}"/>
            	<input type="hidden" id="logoLocPath" name="logoLocPath" value="${oneAppInfo.logoLocPath}"/>
				<div id="uploadfile">
                  <img width="100px" src="${pageContext.request.contextPath}/${oneAppInfo.logoPicPath}">
				<input id="a_logoPicPath"  type="file" class="form-control col-md-7 col-xs-12" name="a_logoPicPath">
				<p><span style="color:red;font-weight: bold;">*注：1、大小不得超过500k.2、图片格式：jpg、png、jpeg、pneg</span></p>
				</div>
				<div id="logoFile"></div>
				${fileUploadError }
            </div>
          </div>
          <div class="form-group">
            <div class="col-md-6 col-md-offset-3">
            	<c:if test="${oneAppInfo.status == 3}">
            	 	<button id="send" type="submit" name="status" value="1" class="btn btn-success">保存并再次提交审核</button>
            	</c:if>
              <button id="send" type="submit" class="btn btn-success">保存</button>
              <button type="button" class="btn btn-primary" name="back" id="back">返回</button>
              <br/><br/>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
<%@include file="common/footer.jsp"%>
<script>
    $(function(){  //加载
        //发送异步请求，获取数所据
        //加载平台
        $.get("${pageContext.request.contextPath}/getPingTaiDataDictionary",null,function(data){
            for(var i=0;i<data.length;i++){
                var node=$("<option value='"+data[i].valueid+"'>"+data[i].valuename+"</option>");
                $("#queryFlatformId").append(node);
            }
            //设置下拉列表选中项
            $("#queryFlatformId").val(${oneAppInfo.flatformId});
        },"json");

        //加载一级分类
        $.get("${pageContext.request.contextPath}/getAppCategoryBySanji",null,function(data){
            for(var i=0;i<data.length;i++){
                var node=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
                $("#queryCategoryLevel1").append(node);
            }
            //设置下拉列表选中项
            $("#queryCategoryLevel1").val(${oneAppInfo.categoryLevel1});
            //加载二级分类
            loadTwo();
        },"json");

        //为一级下拉列表添加change事件：实现二级联动
        function loadTwo(){
            // alert("我要加载二级分类");
            //通过选择的一级分类id,去查询对应的子类
            //清除下拉列表的现有项
            $("#queryCategoryLevel2>option:gt(0)").remove();
            $("#queryCategoryLevel3>option:gt(0)").remove();
            var parentId=$("#queryCategoryLevel1").val();
            if(parentId!=""){
                $.get("${pageContext.request.contextPath}/getAppCategoryBySanji",{"parentid":parentId},function(data){
                    for(var i=0;i<data.length;i++){
                        var node=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
                        $("#queryCategoryLevel2").append(node);
                    }
                    //设置下拉列表选中项
                    $("#queryCategoryLevel2").val(${oneAppInfo.categoryLevel2});
                    //加载三级
                    loadThree();
                },"json");
            }
        }
        $("#queryCategoryLevel1").change(loadTwo);

        //为二级下拉列表添加change事件：实现二级联动
        function loadThree(){
            //通过选择的一级分类id,去查询对应的子类
            //清除下拉列表的现有项
            $("#queryCategoryLevel3>option:gt(0)").remove();
            var parentId=$("#queryCategoryLevel2").val();
            if(parentId!=""){
                $.get("${pageContext.request.contextPath}/getAppCategoryBySanji",{"parentid":parentId},function(data){
                    for(var i=0;i<data.length;i++){
                        var node=$("<option value='"+data[i].id+"'>"+data[i].categoryname+"</option>");
                        $("#queryCategoryLevel3").append(node);
                    }
                    //设置下拉列表选中项
                    $("#queryCategoryLevel3").val(${oneAppInfo.categoryLevel3});

                },"json");
            }
        }
        $("#queryCategoryLevel2").change(loadThree);

        $("button[name='back']").click(function () {
            location.href="${pageContext.request.contextPath}/getAppinfoAll"
        })
    });

</script>